package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsBrandMapper;
import com.qf.pojo.DtsBrand;
import com.qf.service.DtsBrandService;
import com.qf.vo.CatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zwnan
 */
@Service
public class DtsBrandServiceImpl implements DtsBrandService {
    @Autowired
    private DtsBrandMapper dtsBrandMapper;


    @Override
    public IPage<DtsBrand> findPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsBrand> iPage = new Page<DtsBrand>(page,limit);

        return dtsBrandMapper.selectPage(iPage,new QueryWrapper<DtsBrand>().eq("deleted", false));
    }

    @Override
    public void update(DtsBrand dtsBrand) {
        dtsBrandMapper.updateById(dtsBrand);
    }

    @Override
    public void delete(DtsBrand dtsBrand) {
        dtsBrand.setDeleted(true);
        dtsBrandMapper.updateById(dtsBrand);
    }

    @Override
    public List<CatVo> selectName() {
        return dtsBrandMapper.selectName();
    }
}
